<?php
namespace app\serverorder\model;

use \app\manage\model\BaseModel;
/**
 * @author:      李颖
 * @DateTime:    2017-10-13 11:46:18
 * @Description: 订单模型
 */
class Order extends BaseModel
{
	protected $name = 'order';
    protected $connection = 'db_config_order';
    protected $dateFormat = 'Y-m-d H:i:s';
    protected $statusText = [0=>'未付款', 1=>'支付成功'];
    protected $exceptionsStatusText = [0=>'正常', 1=>'已取消', 2=>'已超时', 3=>'已冻结', 4=>'已仲裁/协商'];
    protected $append = ['status_text','exceptions_status_text'];

    public function getStatusTextAttr($value, $data)
    {
        if($data['exceptions_status'] != 0){
            return $this->exceptionsStatusText[$data['exceptions_status']];
        }
        return $this->statusText[$data['status']];
    }

    public function getExceptionsStatusTextAttr($value, $data)
    {
        return $this->exceptionsStatusText[$data['exceptions_status']];
    }

    public function setGoodsInfosAttr($value, $data)
    {
        return json_encode($data['goods_infos']);
    }
   
    public function getGoodsInfosAttr($value,$data)
    {
        return json_decode($data['goods_infos'], true);
    }
    
    public function setTotalOtherPriceAttr($value, $data)
    {
        return json_encode($data['total_other_price']);
    }
   
    public function getTotalOtherPriceAttr($value,$data)
    {
        return json_decode($data['total_other_price'], true);
    }
  
}